%This function reads numerical data corresponding to a set of column
%vectors
%created by Ricardo Mejia-Alvarez. Urbana, IL. 05/09/2010
%modified:  07/25/2010


% function varargout = vectorLoader(path)
function A = vectorLoader(path)

m = fopen(path,'r');      %open the file selected

fgets(m);  %discards all the characters before the numerical data.
first = fgets(m);   %reads the first line of data
first = str2num(first); %#ok<ST2NM>
nc = length(first); %calculates the number of columns in the files
                                            
C = textscan(m,'%f64'); %reads the numerical data from the file
A = C{:};     %saves the data in a vector
A = [first' ; A];

A = reshape(A,nc,length(A)/nc)';

% varargout = cell(1,nc);
% 
% for k = 1 : nc
%     U = A(:,k);
%     varargout(k) = {U};
% end

fclose(m);      %closes the current file

end